//package com.itkaien.javaeebased.Iodemo;
//
//import com.alibaba.fastjson2.JSONArray;
//import com.alibaba.fastjson2.JSONObject;
//import org.springframework.web.service.invoker.UrlArgumentResolver;
//
//import java.io.IOException;
//import java.io.InputStream;
//import java.io.InputStreamReader;
//import java.net.MalformedURLException;
//import java.net.URL;
//import java.net.URLConnection;
//import java.util.*;
//import java.util.regex.Matcher;
//import java.util.regex.Pattern;
//import java.util.stream.Collectors;
//
//public class Test01 {
//
//
//    public static void main(String[] args) throws IOException {
//
//        /**
//         * 制造假数据
//         * 获取姓氏：https://hanyu.baidu.com/shici/detail?pid=0b2f26d4c0ddb3ee693fdb11137eeb0d&from=kg0
//         * 获取男生名字：https://www.haoming8.cn/baobao/10881.html
//         * 获取女生名字：https://www.haoming8.cn/baobao/7641.html
//         */
//
//        List<String> strings = webCrawler("https://baijiaxing.bmcx.com/");
//        JSONObject map = webCrawler1("http://www.haoming123.cn/");
//
//        int i =new Random().nextInt(1,3);
//        List<String> Name = new ArrayList<>();
//
//
//        for (int j = 0; j <100; j++) {
//            String surName = strings.get(new Random().nextInt(strings.size()));
//            String LastNameboy="";
//            String LastNamegirl="";
//
//            JSONArray boy = map.getJSONArray("男");
//            JSONArray girl = map.getJSONArray("女");
//
//            for (int x = 0; x < i; x++){
//                LastNameboy  += (String) boy.get(new Random().nextInt(boy.size()));
//            }
//            int g =new Random().nextInt(1,3);
//            for (int z = 0; z < g; z++){
//                LastNamegirl  += (String) girl.get(new Random().nextInt(girl.size()));
//            }
//            Name.add(surName+LastNameboy+"-男");
//            Name.add(surName+LastNamegirl+"-女");
//        }
//        Name = Name.stream().distinct().collect(Collectors.toList());
//
//        Name.stream().forEach(
//                System.out::println
//        );
//
//
//    }
//
//    public static List<String> webCrawler(String net) throws IOException {
//
//        List<String> surName = new ArrayList<>();
//        StringBuilder html=new StringBuilder();
//        URL url=new URL(net);
//        URLConnection urlConnection = url.openConnection();
//        InputStreamReader inputStreamReader = new InputStreamReader(urlConnection.getInputStream());
//        int len;
//        char[] chars=new char[1024];
//        while ((len=inputStreamReader.read(chars))!=-1){
//            html.append(chars,0,len);
//        }
//        Pattern pattern = Pattern.compile("<span class=\"asdasd1\">(.*?)</span>");
//        Matcher matcher = pattern.matcher(html);
//        while (matcher.find()) {
//            String spanContent = matcher.group(0);
//            Pattern aPattern = Pattern.compile("<a[^>]*>([^<]+)</a>");
//            Matcher aMatcher = aPattern.matcher(spanContent);
//            while (aMatcher.find()) {
//                surName.add(aMatcher.group(1));
//            }
//        }
//        inputStreamReader.close();
//        return surName;
//    }
//
//    public static JSONObject webCrawler1(String net) throws IOException {
//
//        JSONObject manOrGirlOne = new JSONObject();
//        StringBuilder html=new StringBuilder();
//        URL url=new URL(net);
//        URLConnection urlConnection = url.openConnection();
//        InputStreamReader inputStreamReader = new InputStreamReader(urlConnection.getInputStream());
//        int len;
//        char[] chars=new char[1024];
//        while ((len=inputStreamReader.read(chars))!=-1){
//            html.append(chars,0,len);
//        }
//
//        Pattern pattern = Pattern.compile("<div class=\"mzdq\">(.*?)</div>", Pattern.DOTALL);
//        Matcher matcher = pattern.matcher(html);
//
//        System.out.println(matcher.find());
//        while (matcher.find()) {
//            String targetContent = matcher.group(1);
////            System.out.println(targetContent);
//            String key ="";
//            if (targetContent.contains("男")){
//                key="男";
//            }else{
//                key="女";
//            }
//            Pattern aPattern = Pattern.compile("<a[^>]*>([^<]+)</a>");
//            Matcher aMatcher = aPattern.matcher(targetContent);
//            List<String> list = new ArrayList<>();
//            while (aMatcher.find()) {
//                list.add(aMatcher.group(1));
//            }
//            manOrGirlOne.put(key,list);
//        }
//        inputStreamReader.close();
//        return manOrGirlOne;
//    }
//
//}
